package com.learn.springbootcache.mapper;

import com.learn.springbootcache.bean.Employee;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Jmy
 */
@Mapper
@Repository
public interface EmployeeMapper {

    @Select("SELECT * FROM employee WHERE id = #{id}")
    Employee getEmployeeById(Integer id);

    @Update("UPDATE employee SET name = #{name},code = #{code},org_id = #{orgId} WHERE id = #{id}")
    int updateEmployee(Employee employee);

    @Insert("INSERT INTO employee(name,code,org_id) VALUES (#{name},#{code},#{orgId})")
    void insertEmployee(Employee employee);

    @Delete("DELETE FROM employee WHERE id = #{id}")
    void delEmployee(Integer id);

    @Select("SELECT * FROM employee WHERE name = #{name}")
    List<Employee> empList(String name);

}
